const express = require("express");
const app = express();
const path = require('path');
app.listen(8080,()=>{
    console.log('服务启动成功，端口8080')});
// 连接数据库
require('./middleware/mongoose');
// 中间件
app.use(require('./middleware/cors'));
app.use(require('./middleware/session'));
// 数据处理
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(express.static('./public'));
// 路由监听
app.use('/',require("./router/index"));

app.get('*',(req,res)=>{
    res.sendFile(path.join(__dirname,'./public/index.html'));
})